package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name = "PEOPLE_PROPERTY_VALUE")
public class PeoplePropertyValue extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	private Long id;
	@NotBlank @Length(max=50)
	private String propertyValue;
	@NotNull 
	private Long propertyId;
	@NotNull 
	private Long sorting;
	@NotBlank @Length(max=1)
	private String status;
	@NotBlank @Length(max=1)
	private String websiteShow;
	@NotBlank @Length(max=1)
	private String planShow;
	//columns END


	public PeoplePropertyValue(){
	}

	public PeoplePropertyValue(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "PROPERTY_VALUE", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public String getPropertyValue() {
		return this.propertyValue;
	}
	
	public void setPropertyValue(String value) {
		this.propertyValue = value;
	}
	
	@Column(name = "PROPERTY_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getPropertyId() {
		return this.propertyId;
	}
	
	public void setPropertyId(Long value) {
		this.propertyId = value;
	}
	
	@Column(name = "SORTING", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getSorting() {
		return this.sorting;
	}
	
	public void setSorting(Long value) {
		this.sorting = value;
	}
	
	@Column(name = "STATUS", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public String getStatus() {
		return this.status;
	}
	
	public void setStatus(String value) {
		this.status = value;
	}
	
	@Column(name = "WEBSITE_SHOW", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public String getWebsiteShow() {
		return this.websiteShow;
	}
	
	public void setWebsiteShow(String value) {
		this.websiteShow = value;
	}
	
	@Column(name = "PLAN_SHOW", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public String getPlanShow() {
		return this.planShow;
	}
	
	public void setPlanShow(String value) {
		this.planShow = value;
	}
	
	private PeopleProperty peopleProperty;
	public void setPeopleProperty(PeopleProperty peopleProperty){
		this.peopleProperty = peopleProperty;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "PROPERTY_ID",nullable = false, insertable = false, updatable = false) 
	})
	public PeopleProperty getPeopleProperty() {
		return peopleProperty;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("PropertyValue",getPropertyValue())
			.append("PropertyId",getPropertyId())
			.append("Sorting",getSorting())
			.append("Status",getStatus())
			.append("WebsiteShow",getWebsiteShow())
			.append("PlanShow",getPlanShow())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof PeoplePropertyValue == false) return false;
		if(this == obj) return true;
		PeoplePropertyValue other = (PeoplePropertyValue)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return null;
	}
}

